<?
require_once("base/BaseGalleryForm.php");
require_once("cms/core/om/Image.php");

class GalleryForm extends BaseGalleryForm {

    private $log;

    public function __construct() {
        parent::__construct();
        $this->log =& LoggerManager::getLogger("GalleryForm");
        $this->getGallery()->setImageRelatedByImageId(new Image());
        $this->getGallery()->setImageRelatedByThumbnailId(new Image());
    }

    public function validate() {

        global $ALLOWABLE_IMAGES;

        $ALLOWABLE_IMAGES = array(
            "image/jpeg"=>"jpg",
            "image/pjpeg"=>"jpg",
            "image/gif"=>"gif",
            "image/png"=>"png"
        );

        $errors = parent::validate();

        if($this->getGallery()->getGalleryId() == 0)
            if(is_null($this->getGallery()->getType()) || strlen($this->getGallery()->getType()) == 0)
                $errors->add("gallery->type",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.type", true)));


        return $errors;
    }

}
?>